﻿using System;
using System.Collections.Generic;
using System.Text;

namespace XDesigner.ORM.Test
{
    [Serializable()]
    [ORMType("Orders")]
    [System.ComponentModel.TypeConverter(typeof(MyTypeConverter))]
    public class OrderClass
    {
        /// <summary>
        /// Initialize instance
        /// </summary>
        public OrderClass()
        {
        }

        private int _OrderID = 0;
        /// <summary>
        /// Order id
        /// </summary>
        [ORMKeyField()]
        [ORMNewValueGenerate( ORMNewValueGenerateStyle.Increase )]
        public int OrderID
        {
            get { return _OrderID; }
            set { _OrderID = value; }
        }

        //private string _CustomerID = null;

        //public string CustomerID
        //{
        //    get
        //    {
        //        return _CustomerID;
        //    }
        //    set
        //    {
        //        _CustomerID = value; 
        //    }
        //}

        private CustomerClass _Customer = null;
        [ORMField("CustomerID")]
        [ORMRelation(ORMRelationStyle.OneToOne,LogReference=false)]
        [ORMDelay()]
        public virtual CustomerClass Customer
        {
            get { return _Customer; }
            set { _Customer = value; }
        }


        private EmployeeClass _Employee = null;
        [ORMRelation( ORMRelationStyle.OneToOne,LogReference=false )]
        [ORMField("EmployeeID")]
        [ORMDelay()]
        public virtual EmployeeClass Employee
        {
            get { return _Employee; }
            set { _Employee = value; }
        }

        //private int _EmployeeID = 0;

        //public int EmployeeID
        //{
        //    get { return _EmployeeID; }
        //    set { _EmployeeID = value; }
        //}

        private DateTime _OrderDate = DateTime.Now;

        public DateTime OrderDate
        {
            get { return _OrderDate; }
            set { _OrderDate = value; }
        }

        private DateTime _RequiredDate = DateTime.Now;

        public DateTime RequiredDate
        {
            get { return _RequiredDate; }
            set { _RequiredDate = value; }
        }

        private DateTime _ShippedDate = DateTime.Now;

        public DateTime ShippedDate
        {
            get { return _ShippedDate; }
            set { _ShippedDate = value; }
        }

        private float _ShipVia = 0f;

        public float ShipVia
        {
            get { return _ShipVia; }
            set { _ShipVia = value; }
        }

        private decimal _Freight = 0m;

        public decimal Freight
        {
            get { return _Freight; }
            set { _Freight = value; }
        }

        private string _ShipName = null;

        public string ShipName
        {
            get { return _ShipName; }
            set { _ShipName = value; }
        }

        private string _ShipAddress = null;

        public string ShipAddress
        {
            get { return _ShipAddress; }
            set { _ShipAddress = value; }
        }

        private string _ShipCity = null;

        public string ShipCity
        {
            get { return _ShipCity; }
            set { _ShipCity = value; }
        }

        private string _ShipRegion = null;

        public string ShipRegion
        {
            get { return _ShipRegion; }
            set { _ShipRegion = value; }
        }

        private string _ShipPostalCode = null;

        public string ShipPostalCode
        {
            get { return _ShipPostalCode; }
            set { _ShipPostalCode = value; }
        }

        private string _ShipCountry = null;

        public string ShipCountry
        {
            get { return _ShipCountry; }
            set { _ShipCountry = value; }
        }

        private List<OrderDetailClass> _OrderDetails = null;
        [ORMRelation(ORMRelationStyle.OneToMany, "OrderID", UniteDeleteForDelete = true)]
        [ORMDelay()]
        public virtual List<OrderDetailClass> OrderDetails
        {
            get { return _OrderDetails; }
            set { _OrderDetails = value; }
        }

        public override string ToString()
        {
            return "Order:" + this.OrderID;
        }
    }
}
